{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "text_file = open(\"data.txt\", \"r\")\n",
    "lines = text_file.read()\n",
    "counter = 1\n",
    "data = []\n",
    "while True:\n",
    "    temp = lines.split('\\n'+str(counter)+'. ')\n",
    "    if len(temp)==2:\n",
    "        data.append(temp[0])\n",
    "        lines = temp[1]\n",
    "    else:\n",
    "        break\n",
    "    counter += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "stop_words = set(stopwords.words('english'))\n",
    "porter = PorterStemmer()\n",
    "tokens = []\n",
    "for i in range(len(data)):\n",
    "    temp = word_tokenize(data[i])\n",
    "    temp = [word.lower() for word in temp]\n",
    "    temp = [word for word in temp if not word in stop_words]\n",
    "    temp = [porter.stem(word) for word in temp]\n",
    "    tokens.append([word for word in temp if word.isalpha()])\n",
    "    # tokens.append(word_tokenize(data[i]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
